package cn.seecoder.ai.model.bo;

import cn.seecoder.ai.enums.TrainParamEnum;
import lombok.Data;

import java.util.Map;

import static cn.seecoder.ai.utils.DataTypeHelper.*;

/**
 * @author fanyanpeng
 * @date 2023/4/20 3:53
 */
@Data
public class TrainParamsBO {


    // 以下是内部参数，不需要外部调用者传入
    public Integer featureDimensionNum;

    public Integer labelUniqueNum;

    //以下是外部参数，需要调用者确认

    public Integer maxCategories;


    public Integer maxIter;

    public Integer maxDepth;

    public Integer maxBins;

    public Integer minInstancesPerNode;

    public Integer k;

    public Integer numTrees;

    public Double minInfoGain;

    public Double elasticNetParam;

    public Double trainingDataSetOccupy;

    public Double regParam;

    public Integer blockSize;


    public  Long seed;

    public TrainParamsBO(Map<TrainParamEnum,Object> params){

        featureDimensionNum= toInteger( TrainParamEnum.FEATURE_DIMENSION_NUM.readTrainParamMap(params));
        labelUniqueNum = toInteger( TrainParamEnum.FEATURE_DIMENSION_NUM.readTrainParamMap(params));
        maxCategories = toInteger( TrainParamEnum.MAX_CATEGORIES.readTrainParamMap(params));
        maxIter= toInteger( TrainParamEnum.MAX_ITER.readTrainParamMap(params));
        maxDepth= toInteger( TrainParamEnum.MAX_DEPTH.readTrainParamMap(params));
        maxBins= toInteger( TrainParamEnum.MAX_BINS.readTrainParamMap(params));
        minInstancesPerNode= toInteger( TrainParamEnum.MIN_INSTANCES_PER_NODE.readTrainParamMap(params));
        k= toInteger( TrainParamEnum.K.readTrainParamMap(params));
        numTrees=toInteger( TrainParamEnum.NUM_TREES.readTrainParamMap(params));
        blockSize=toInteger( TrainParamEnum.BLOCK_SIZE.readTrainParamMap(params));

        minInfoGain= toDouble( TrainParamEnum.MIN_INFO_GAIN.readTrainParamMap(params));
        elasticNetParam= toDouble( TrainParamEnum.ELASTIC_NET_PARAM.readTrainParamMap(params));
        trainingDataSetOccupy= toDouble( TrainParamEnum.TRAIN_DATA_SET_OCCUPY.readTrainParamMap(params));
        regParam= toDouble( TrainParamEnum.REG_PARAM.readTrainParamMap(params));

        seed= toLong(TrainParamEnum.SEED.readTrainParamMap(params));
    }
    


}
